
package org.wing.mouseListener;

import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import javax.swing.Icon;
import org.come.until.CutButtonImage;
import org.wing.panel.WingMainPanel;

public class ChooseRefiningCheckboxMouseListener extends MouseAdapter {
    private int p;
    private WingMainPanel wingMainPanel;

    public ChooseRefiningCheckboxMouseListener(int p, WingMainPanel wingMainPanel) {
        this.p = p;
        this.wingMainPanel = wingMainPanel;
    }

    @Override
    public void mousePressed(MouseEvent e) {
        int num = 0;

        int refiningMoney;
        for(refiningMoney = 0; refiningMoney < this.wingMainPanel.getWingRefiningType().length; ++refiningMoney) {
            if (this.wingMainPanel.getWingRefiningType()[refiningMoney]) {
                ++num;
            }
        }

        if (this.wingMainPanel.getWingRefiningType()[this.p]) {
            this.wingMainPanel.getWingRefining()[this.p].setIcon((Icon)null);
            --num;
        } else {
            if (num >= 3) {
                return;
            }

            this.wingMainPanel.getWingRefining()[this.p].setIcon(CutButtonImage.getImage("inkImg/hongmu/2/showjadesuit.png", 15, 15));
            ++num;
        }

        refiningMoney = this.wingMainPanel.getRefiningMoney(num);
        this.wingMainPanel.getRefiningTitle().setText("当前锁定花费仙玉为：" + refiningMoney + "仙玉");
        this.wingMainPanel.getWingRefiningType()[this.p] = !this.wingMainPanel.getWingRefiningType()[this.p];//设置锁
    }
}
